var builder = WebApplication.CreateBuilder(args).Inject();
var app = builder.Build();
app.Map("/demo", () => "Hello World");
var handler = new HelloHandler();
var router = new RouteHandler();

//minimal api
app.MapGet("/demo1", handler.Hello);
app.MapGet(router.str, handler.Hello);

app.Run();

#region == minimal api ==
class RouteHandler
{
    public string str { get; set; }
    public RouteHandler()
    {
        str = Router();
    }
    public string Router()
    {
        return "/demo2";
    }
}
class HelloHandler
{
    public string Hello()
    {
        return "Hello World2";
    }
}
#endregion